package com.xmx.mallcenter.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import com.xmx.mallcenter.entity.RegionEntity;
import com.xmx.mallcenter.service.RegionService;
import com.xmx.common.utils.PageUtils;
import com.xmx.common.utils.R;
import io.swagger.annotations.Api;


/**
 * 行政区域表
 *
 * @author fbb
 * @email boyinbing@126.com
 * @date 2021-08-12 01:42:20
 */
@Api(tags = "RegionController", description = "行政区域表服务")
@RestController
@RequestMapping("mallcenter/region")
public class RegionController {
    @Autowired
    private RegionService regionService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("mallcenter:region:list")
    @ApiOperation("获取所有行政区域表信息")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = regionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("mallcenter:region:info")
    @ApiOperation("获取指定id的行政区域表详情")
    public R info(@PathVariable("id") Integer id){
		RegionEntity region = regionService.getById(id);

        return R.ok().put("region", region);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加行政区域表信息")
    //@RequiresPermissions("mallcenter:region:save")
    public R save(@RequestBody RegionEntity region){
		regionService.save(region);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation("更新指定id行政区域表信息")
    //@RequiresPermissions("mallcenter:region:update")
    public R update(@RequestBody RegionEntity region){
		regionService.updateById(region);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除指定id行政区域表信息")
    //@RequiresPermissions("mallcenter:region:delete")
    public R delete(@RequestBody Integer[] ids){
		regionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
